<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .bg {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }

    .drawer {
        position: fixed;
        top: 0;
        right: 0;
        width: 50%;
        height: 100%;
        background: #304156;
        z-index: 10;
        transition: all 0.3s;
    }

    .show {
        transform: translateX(0);
    }

    .hidden {
        transform: translateX(100%);
    }
</style>

<body>
    <div class="box">
        <button v-on:click="getPop()">点击按钮</button>
        <div class="bg" v-if="isShow" v-on:click="closePop()"></div>
        <div class="drawer" :class="isShow ? 'show' : 'hidden'"></div>
    </div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    new Vue({
        el: '.box',
        data() {
            return {
                isShow: false
            }
        },
        methods: {
            getPop() {
                this.isShow = true
            },
            closePop() {
                this.isShow = false
            }
        }
    })
</script>

</html>

